<?php

namespace Modules\WeChat\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Modules\WeChat\Service\ShopService;

class ShopController extends Controller
{
    /**
     * 公证号入驻申请（加入我们）
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function settledIn(Request $request)
    {
        $data = $request->all();

        $res = ShopService::create($data);

        return response_json($res);
    }

    /**
     * 获取店铺信息
     * @return \Illuminate\Http\JsonResponse
     */
    public function getShopDetail()
    {
        $s_openid = get_wat_token();

        $res = ShopService::getDetail($s_openid);

        return response_json($res);
    }

    /**
     * 店铺数据统计
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function statistics(Request $request)
    {
        $data = $request->all();
        $arr_admin = wechat_user();
        $n_shop_id = intval($arr_admin->shop_id);
        $res = \HiCommon\Service\ShopService::api_graphs_statistics($n_shop_id, $data);

        return response_json($res);
    }

    /**
     * 获取维修店的订单记录（积分订单，服务订单，现金订单）
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function getShopOrder(Request $request)
    {
        $data = $request->all();

        $res = ShopService::getShopOrder($data);
        dd($res);
        return response_json($res);
    }
}
